﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace SimoBotGUI
{
    public partial class frmConnect : Form
    {

        //public frmMain MainForm;
        //private SimoBotEngine engine;

        string Server;
        int Port;
        string Channel;
        string Nick;
        /*
        public string GetServer() { return Server; }
        public int GetPort() { return Port; }
        public string GetChannel() { return Channel; }
        public string GetNick() { return Nick; }
        */
        public frmMain MainForm;
        public frmConnect(frmMain FormMain)
        {
            InitializeComponent();
            MainForm = FormMain;
        }

        public bool isNumber(string str)       // If conversion fails, means string is not numeric
        {
            try
            {
                Convert.ToInt32(str);
            }
            catch
            {
                return false;
            }
            return true;
        }

           
        private void btnConnect_Click_1(object sender, EventArgs e)
        {
                    
            try
            {
            Port = Convert.ToInt32(txtPort.Text);
            }

            catch (FormatException f)
            {
                txtPort.Text="Plz numbrs only";
            }

            catch(OverflowException f)
            {
                txtPort.Text="Short number kthx";
            }

            if(isNumber(txtPort.Text))
            {
                Server = txtServer.Text;
                Channel = txtChannel.Text;
                Nick = txtNick.Text;

                //frmMain MainForm = new frmMain();
                MainForm.DerpText(txtServer.Text, Port, txtChannel.Text, txtNick.Text);
                //MainForm.Show();
                this.Close(); 
            }
        }
    }
}
